package view
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.utils.setTimeout;
	
	public class TextSprite extends Sprite
	{
		public var txt:TextField;
		private var _fontface:String = '微软雅黑';
		private var _color:String = "000000";
		private var _size:int = 15;
		private var content:String = "请输入文字";
		public function TextSprite()
		{
			txt = new TextField;
			txt.autoSize = TextFieldAutoSize.LEFT;
			this.addChild(txt);
			//txt.selectable = false;
			//txt.text = "请输入文字"
			txt.htmlText = "<font face='" + _fontface + "' size='" + _size + "' color='#" + _color + "'>" + content + "</font>";
			//txt.addEventListener(,draw);
		}
		public function set text(value:String):void{
			this.content = value;
			txt.htmlText = "<font face='" + _fontface + "' size='" + _size + "' color='#" + _color + "'>" + value + "</font>";
			setTimeout(draw,10);
		}
		public function draw():void{
			this.graphics.clear();
			this.graphics.beginFill(0xffff00,0);
			this.graphics.drawRect(0,0,this.width,this.height);
			this.graphics.endFill();
			this.dispatchEvent(new Event(Event.CHANGE));
		}
		public function set fontface(value:String):void
		{
			_fontface = value;
			txt.htmlText = "<font face='" + _fontface + "' size='" + _size + "' color='#" + _color + "'>" + content + "</font>";
			setTimeout(draw,10);
		}

		public function set color(value:String):void
		{
			_color = value;
			txt.htmlText = "<font face='" + _fontface + "' size='" + _size + "' color='#" + _color + "'>" + content + "</font>";
			setTimeout(draw,10);
		}
		public function set size(value:int):void{
			_size = value;
			txt.htmlText = "<font face='" + _fontface + "' size='" + _size + "' color='#" + _color + "'>" + content + "</font>";
			setTimeout(draw,10);
		}
		public function get size():int{
			return _size;
		}
		public function getStr():String{
			return encodeURI(txt.htmlText);
		}
		
		

	}
}